package org.codegallery.javagal.concurrent.cpj;

import EDU.oswego.cs.dl.util.concurrent.Mutex;

public class WithMutex {
	private final Mutex mutex;

	public WithMutex(Mutex m) {
		mutex = m;
	}

	public void perform(Runnable r) throws InterruptedException {
		mutex.acquire();
		try {
			r.run();
		} finally {
			mutex.release();
		}
	}

}
